<template>
  <div>
    <TypeNav></TypeNav>
    <ListContainer></ListContainer>
    <TodayRecommend></TodayRecommend>
    <Rank></Rank>
    <Like></Like>
    <Floor v-for="floor in floorList" :key="floor.id" :floor="floor"></Floor>
    <Brand></Brand>
  </div>
</template>

<script>
import ListContainer from "./ListContainer";
import TodayRecommend from "./TodayRecommend";
import Rank from "./Rank";
import Like from "./Like";
import Floor from "./Floor";
import Brand from "./Brand";
/* 引入辅助函数 */
import { mapState } from "vuex";
export default {
  name: "Home",
  components: {
    ListContainer,
    TodayRecommend,
    Rank,
    Like,
    Floor,
    Brand,
  },
  computed: {
    /* 通过辅助函数拿到vuex中的数据 */
    ...mapState({
      floorList: (state) => state.home.floorList,
    }),
  },
  mounted() {
    this.getFloorList();
  },
  methods: {
    /* 发送请求拿floorlist数据 */
    getFloorList() {
      this.$store.dispatch("reqFloorList");
    },
  },
};
</script>
